<style lang="less" scoped>
.panel {
  margin-bottom: 10px;
  &-title {
    display: flex;
    padding: 10px;
    border-bottom: 0.1px solid #eaeaea;
    background: white;

    &__label {
      flex: 1;
      font-size: 16px;
      align-items: center;
    }
  }
  &-content {
    margin-bottom: 10px;
    background: white;

    &__item {
      display: flex;
      // padding: 10px 10px 0 10px;
      font-size: 14px;
      &-label {
        color: #666;
        border-bottom: 0.1px solid #eaeaea;
        border-right: 0.1px solid #eaeaea;
        padding: 6px 0 6px 6px;
        flex: 1;
      }
      &-value {
        flex: 1;
        padding-left: 15px;
        color: #333;
        border-bottom: 0.1px solid #eaeaea;
        padding: 6px;
      }
    }
  }
}
</style>

<template>
  <div>
    <load v-if="loading"></load>
    <div v-else-if="items.length==0" class="info">暂无数据</div>
    <div class="panel" v-else>
      <!-- title -->
      <div class="panel-title">
        <div class="panel-title__label">主要指标</div>
        <div class="panel-title__right">
          <select name="" id="">
            <option value="1"></option>
            <option value="12"></option>
            <option value="13"></option>
          </select>
        </div>
      </div>
      <!-- content -->
      <div class="panel-content" v-for="(item, index) in items" :key="index">
        <div class="panel-content__item" v-for="(item1, index1) in item" :key="index1">
          <div class="panel-content__item-label">{{item1.label}}</div>
          <div class="panel-content__item-value" v-if="item1.value">{{item1.value}}</div>
          <div class="panel-content__item-right"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Load from '@/components/load';
export default {
  components: { Load },
  computed: {
    loading() {
      return this.$store.getters.loading;
    }
  },
  data() {
    return {
      items: []
    };
  },
  onLoad() {
    // 显示页面初始化
    this.init();
  },
  onUnload() {
    // 卸载时清理数据
    this.items = {};
  },
  methods: {
    init() {
      // 初始化获取公司信息
      const CompanyCode = this.$route.query.CompanyCode;

      this.url = CompanyCode
        ? '/xcx/getIpoFinancialData'
        : '/xcx/getFinancesList'; //上市公司存在公司编码，非上市公司不存在公司编码
      this.CompanyCode = CompanyCode;
      this.getInfos();
    },
    async getInfos() {
      const url = this.url;
      var params = {};
      if (this.CompanyCode) {
        // 上市公司
        params.companyCode = this.CompanyCode;
      } else {
        //非上市公司
        params.unique = this.$route.query.Unique;
      }
      const res = await this.$http.get(url, params);
      if (this.CompanyCode) {
        const item1 = res.result.Result;
        this.items = [
          [
            { label: '每股指标', value: '' },
            { label: '基本每股收益(元)', value: item1.PerIndex.PerBaseIncome },
            {
              label: '扣非每股收益(元)',
              value: item1.PerIndex.PerBuckleIncome
            },
            {
              label: '稀释每股收益(元)',
              value: item1.PerIndex.PerDilutedIncome
            },
            { label: '每股净资产(元)', value: item1.PerIndex.PerNetAssets },
            {
              label: '每股公积金(元)',
              value: item1.PerIndex.PerAccumulationFund
            },
            {
              label: '每股未分配利润(元)',
              value: item1.PerIndex.UndistributedEarnings
            },
            {
              label: '每股经营现金流(元)',
              value: item1.PerIndex.OperatingCashFlow
            },

            { label: '成长能力指标', value: '' },
            {
              label: '营业收入(元)',
              value: item1.PerIndex.TotalOperatingIncome
            },
            { label: '毛利润(元)', value: item1.PerIndex.GrossPprofit },
            {
              label: '归属净利润(元)',
              value: item1.PerIndex.NetProfitAttributable
            },
            {
              label: '扣非净利润(元)',
              value: item1.PerIndex.DeductionNetProfit
            },
            {
              label: '营业总收入同比增长(%)',
              value: item1.PerIndex.TotalOperatingIncomeGrew
            },
            {
              label: '归属净利润同比收入(%)',
              value: item1.PerIndex.AttributableNetProfitRose
            },
            {
              label: '扣非净利润同比增长(%)',
              value: item1.PerIndex.NetProfitRose
            },
            {
              label: '营业总收入滚动环比增长(%)',
              value: item1.PerIndex.TotalOperatingIncomeGrowth
            },
            {
              label: '归属净利润滚动环比增长(%)',
              value: item1.PerIndex.NetProfitAttributableRollingGrowth
            },
            {
              label: '扣非净利润滚动环比增长(%)',
              value: item1.PerIndex.DeductionNonNetProfitGrowth
            },

            { label: '盈利能力指标(%)', value: '' },
            {
              label: '加权净资产收益表(%)',
              value: item1.PerIndex.WeightedReturnNetAssets
            },
            {
              label: '摊薄净资产收益率(%)',
              value: item1.PerIndex.DilutedReturnNetAssets
            },
            {
              label: '摊薄总资产收益率(%)',
              value: item1.PerIndex.DilutedTotalAssetsYield
            },
            { label: '毛利率(%)', value: item1.PerIndex.GrossProfitMargin },
            { label: '净利率(%)', value: item1.PerIndex.NetInterestRate },
            { label: '实际税率(%)', value: item1.PerIndex.EffectiveTaxRate },

            { label: '盈利质量指标', value: '' },
            { label: '预收款/营业收入', value: item1.PerIndex.AdvanceReceipts },
            {
              label: '销售现金流/营业收入',
              value: item1.PerIndex.SalesCashFlow
            },
            {
              label: '经营现金流/营业收入',
              value: item1.PerIndex.OperatingCashFlowIncome
            },

            { label: '运营能力指标', value: '' },
            {
              label: '总资产周转率(次)',
              value: item1.PerIndex.TotalAssetTurnover
            },
            // { label: '总资产周转天数(次)', value: item1.PerIndex.TotalAssetTurnover },
            {
              label: '应收账款周转天数(次)',
              value: item1.PerIndex.AccountsReceivableTurnoverDays
            },
            {
              label: '存货周转天数(次)',
              value: item1.PerIndex.InventoryTurnoverDays
            },

            { label: '财务风险指标', value: '' },
            {
              label: '资产负债率(次)',
              value: item1.PerIndex.AssetLiabilityRatio
            },
            {
              label: '流动总负责/总负责(次)',
              value: item1.PerIndex.CurrentLiabilities
            },
            { label: '流动比率', value: item1.PerIndex.CurrentRatio },
            { label: '速动比率', value: item1.PerIndex.QuickRatio }
          ],
          [
            { label: '资产负债表', value: '' },
            {
              label: '资产:货币资金(元)',
              value: item1.BalanceSheet.MonetaryFund || '-'
            },
            {
              label: '应收账款(元)',
              value: item1.BalanceSheet.AccountsReceivable || '-'
            },
            {
              label: '其他应收款(元)',
              value: item1.BalanceSheet.OtherReceivables || '-'
            },
            { label: '存货(元)', value: item1.BalanceSheet.Stock || '-' },
            {
              label: '流动资产合计(元)',
              value: item1.BalanceSheet.TotalCurrentAssets || '-'
            },
            {
              label: '长期股权投资(元)',
              value: item1.BalanceSheet.LongQuityInvestment || '-'
            },
            {
              label: '累计折旧(元)',
              value: item1.BalanceSheet.AccumulatedDepreciation || '-'
            },
            {
              label: '固定资产(元)',
              value: item1.BalanceSheet.FixedAssets || '-'
            },
            {
              label: '无形资产(元)',
              value: item1.BalanceSheet.IntangibleAssets || '-'
            },
            {
              label: '资产总计(元)',
              value: item1.BalanceSheet.TotalAssets || '-'
            },
            {
              label: '负债：应付账款(元)',
              value: item1.BalanceSheet.AccountsPayable || '-'
            },
            {
              label: '预收账款(元)',
              value: item1.BalanceSheet.QuAccountsReceivable || '-'
            },
            {
              label: '存货跌价准备(元)',
              value: item1.BalanceSheet.InventoryFallingPriceReserves || '-'
            },
            {
              label: '流动负债合计(元)',
              value: item1.BalanceSheet.TotalCurrentLiabilities || '-'
            },
            {
              label: '长期负债合计(元)',
              value: item1.BalanceSheet.TotalLongTermLiabilities || '-'
            },
            {
              label: '负债合计(元)',
              value: item1.BalanceSheet.TotalLiabilities || '-'
            },
            {
              label: '权益:实收资本|股本(元)',
              value: item1.BalanceSheet.CapitalPaid || '-'
            },
            {
              label: '资本公积金(元)',
              value: item1.BalanceSheet.CapitalAccumulationFund || '-'
            },
            {
              label: '盈余公积金(元)',
              value: item1.BalanceSheet.SurplusProvidentFund || '-'
            },
            {
              label: '股东权益合计(元)',
              value: item1.BalanceSheet.TotalStockholdersEquity || '-'
            },
            {
              label: '流动比率(元)',
              value: item1.BalanceSheet.CurrentRatio || '-'
            }
          ],
          [
            { label: '利润表', value: '' },
            {
              label: '营业收入(元)',
              value: item1.IncomeStatement.OperatingIncome || '-'
            },
            {
              label: '营业成本(元)',
              value: item1.IncomeStatement.OperatingCost || '-'
            },
            {
              label: '销售费用(元)',
              value: item1.IncomeStatement.SalesCost || '-'
            },
            {
              label: '财务费用(元)',
              value: item1.IncomeStatement.FinancialExpenses || '-'
            },
            {
              label: '管理费用(元)',
              value: item1.IncomeStatement.ManagementFee || '-'
            },
            {
              label: '资产减值损失(元)',
              value: item1.IncomeStatement.ImpairmentLossesAssets || '-'
            },
            {
              label: '投资收益(元)',
              value: item1.IncomeStatement.InvestmentIncome || '-'
            },
            {
              label: '营业利润(元)',
              value: item1.IncomeStatement.OperatingProfit || '-'
            },
            {
              label: '利润总额(元)',
              value: item1.IncomeStatement.TotalProfit || '-'
            },
            {
              label: '所得税(元)',
              value: item1.IncomeStatement.IncomeTax || '-'
            },
            {
              label: '归属母公司所有者净利润(元)',
              value:
                item1.IncomeStatement.ParentCompanyNetProfitAttributable || '-'
            }
          ],
          [
            { label: '现金流量表', value: '' },
            {
              label: '经营:销售商品、提供劳务收到的现金(元)',
              value: item1.CashFlowStatement.CashReceived || '-'
            },
            {
              label: '收到的税费返还(元)',
              value: item1.CashFlowStatement.TaxRefundReceived || '-'
            },
            {
              label: '收到其他与经营活动有关的现金(元)',
              value: item1.CashFlowStatement.OtherCashReceived || '-'
            },
            {
              label: '经营活动现金流入小计(元)',
              value: item1.CashFlowStatement.CashInflows || '-'
            },
            {
              label: '购买商品、接受劳务支付的现金(元)',
              value: item1.CashFlowStatement.CashPaid || '-'
            },
            {
              label: '支付给职工以及为职工支付的现金(元)',
              value: item1.CashFlowStatement.EmployeesCashPaid || '-'
            },
            {
              label: '支付的各项税费(元)',
              value: item1.CashFlowStatement.TaxesPaid || '-'
            },
            {
              label: '支付其他与经营活动有关的现金(元)',
              value: item1.CashFlowStatement.OtherCashPaid || '-'
            },
            {
              label: '经营活动现金流出小计(元)',
              value: item1.CashFlowStatement.OperatingCashOutflow || '-'
            },
            {
              label: '经营活动产生的现金流量净额(元)',
              value: item1.CashFlowStatement.NetCashFlows || '-'
            },
            {
              label: '投资:取得投资收益所收到的现金(元)',
              value: item1.CashFlowStatement.InvestmentCashReceived || '-'
            },
            {
              label: '处置固定资产、无形资产和其他长期资产回收的现金净额(元)',
              value: item1.CashFlowStatement.AssetsNetCashReceived || '-'
            },
            {
              label: '投资活动现金流入小计(元)',
              value: item1.CashFlowStatement.InvestmentCashInflow || '-'
            },
            {
              label: '购建固定资产、无形资产和其他长期资产支付的现金(元)',
              value: item1.CashFlowStatement.AssetsCashPaid || '-'
            },
            {
              label: '处置固定资产、无形资产和其他长期资产支付的现金净额(元)',
              value: item1.CashFlowStatement.AssetsNetCashPaid || '-'
            },
            {
              label: '投资支付的现金(元)',
              value: item1.CashFlowStatement.InvestmentCashPaid || '-'
            },
            {
              label: '投资活动现金流出小计(元)',
              value: item1.CashFlowStatement.InvestmentCashOutflow || '-'
            },
            {
              label: '投资活动产生的现金流量净额(元)',
              value: item1.CashFlowStatement.InvestingNetCcashFlow || '-'
            },
            {
              label: '筹资:吸收投资收到的现金(元)',
              value:
                item1.CashFlowStatement.AbsorptionInvestmentCashReceived || '-'
            },
            {
              label: '取得借款收到的现金(元)',
              value: item1.CashFlowStatement.BorrowingsCashReceived || '-'
            },
            {
              label: '筹资活动现金流入小计(元)',
              value: item1.CashFlowStatement.FinancingCashInflow || '-'
            },
            {
              label: '偿还债务支付的现金(元)',
              value: item1.CashFlowStatement.DebtCashPaid || '-'
            },
            {
              label: '分配股利、利润或偿付利息支付的现金(元)',
              value: item1.CashFlowStatement.DistributionCashPaid || '-'
            },
            {
              label: '筹资活动现金流出小计(元)',
              value: item1.CashFlowStatement.FinancingCashOutflow || '-'
            },
            {
              label: '筹资活动产生的现金流量净额(元)',
              value: item1.CashFlowStatement.FinancingNetCashFlows || '-'
            }
          ]
        ];
        return;
      }
      const item2 = res.result;
      this.items = [
        [
          { label: '财务总览', value: '' },
          {
            label: '公司实力等级',
            value: item2.FinancingTax.RevenueRange || '-'
          },
          {
            label: '纳税区间',
            value: item2.FinancingTax.TaxRange || '-'
          },
          {
            label: '销售季净利润率',
            value: item2.FinancingTax.NetProfitMargins || '-'
          },
          {
            label: '销售毛利率',
            value: item2.FinancingTax.GrossProfitMargins || '-'
          }
        ]
      ];
    }
  }
};
</script>
